﻿var sayfa = 0;
function IlanBul() {
    $('#divIlanlar li').removeHighlight();
    var src = $('#txtIlanBul').val();
    if (src != ""){
        $('#divIlanlar li').highlight(src);
    }
}

function CreateNewLikeButton(url, container,a) {
    var elem = $(document.createElement("fb:like"));
    elem.attr("href", url);
    elem.attr("data-send", true);
    if (a) {
        elem.attr("data-layout","button_count");
    }
        elem.attr("width", "130px");
    //    elem.attr("height", "100px");
    //    elem.attr("float", "left");
        $('div#' + container).empty().append(elem);
        if (typeof FB != "undefined") {
            
            FB.XFBML.parse(document.getElementById('#' + container))
        }
        FB.XFBML.parse();
    

}
function twitterbuttonYarat() {
    $('.twitter-share-button').each(function (k, v) {
        var tweet_button = new twttr.TweetButton($(this).get(0));
        tweet_button.render();
    });
}
function twttrr() {
    !function (d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (!d.getElementById(id)) {
            js = d.createElement(s); js.id = id;
            js.src = "//platform.twitter.com/widgets.js";
            fjs.parentNode.insertBefore(js, fjs);
        } 
    }
(document, "script", "twitter-wjs");

 }
function CreateNewLikeButton2(container) {
   
    if (typeof FB != "undefined") {
        //FB.XFBML.parse($('#' + container).get(0));
        FB.XFBML.parse(document.getElementById('#' + container))
    }
    FB.XFBML.parse();
}
function okkoy(ustid, altid, facebookLink) {
    $('#AnaSayfaSol .ui-state-default').removeClass("ui-state-default");

    $('.spnbaslik').removeClass("ui-icon ui-icon-circle-triangle-e");
    $('#katbaslik' + ustid).addClass("ui-icon ui-icon-circle-triangle-e");
    if (altid) {
        $('.spnOK').hide();
        $('.secilen#spnOK' + altid).show();
    }

    var t = $("#kategoriKapla" + altid);


    secilenKategoriID = altid;
}
function kategoriHaberleriGetir(kategoriID, haberID, temizleme) {
    $('body').block({
        theme: true,
        message: "Haberler Getiriliyor...",
        css: { border: '3px solid #a00' }
    });

    haberAkisEkrani();

    var json = { kategoriID: kategoriID, sayfa: sayfa };
    $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "mainFuncs.aspx/kategoriHaberleriniGetir",
        data: $.toJSON(json),
        dataType: "json",
        success: function (data) {
            var json = { sparam: "seciliKategori", s: kategoriID };
            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: "mainFuncs.aspx/SessionYaz",
                data: $.toJSON(json),
                dataType: "json",
                success: function (data) {
                },
                error: function (xhr, data, textStatus) {

                }
            });
            if (!temizleme) {
                $('#haberAkis').html("");
            }
            var ustBosluk = '<div class="solyuzdeyuz" style="height:42px">&nbsp</div>';
            if (data.d != null) {

                $.each(data.d, function (key, value) {
                    var eu = 'http://' + window.location.host + '/haberEkleri/' + value.haberID + '/' + value.haberResmi;
                    var resim = '<div class="resimborder" style="width:80px;float:left;margin-left:5px;padding-right:3px;" id="resim' + value.haberID + '" ><img  height=80 width=80 src="http://' + window.location.host + '/haberEkleri/' + value.haberID + '/' + value.haberResmi + '" /></div>';
                    var haberVideo = '<div  class="resimborder" style="width:16.5%;float:left;margin-left:5px;padding-right:5px;"><video preload="auto" style="float:left" class="haberDisVideo' + value.haberID + '" id="haberDisVideo' + value.haberID + '" src="' + eu + '" width="80" height="80" > </video></div>';


                    var res = '<div style="width:15%;float:left;margin-left:5px;padding-right:5px;">&nbsp</div>';
                    if (value.ekTipi != null) {
                        res = value.ekTipi == "R" ? resim : haberVideo;
                    }

                    var logo = value.logo != null ? '<div style="float:left;width:50px;height:50px;margin-top:-15px;">' + value.logo + '  </div>' : "";
                    var eurl = encodeURIComponent('http://' + window.location.host + '/Default.aspx?hid=' + value.haberID);
                    var baslik = '<div class="fnt solyuzdeyuz " style="font-size:11px;font-weight:bold;margin-top:-28px;max-height:2.2em;">' + value.kategoriAdi + '</div>';

                    if (value.ozelSayfa == 'T') {
                        baslik = '<div class="fnt solyuzdeyuz " style="font-size:11px;font-weight:bold;margin-top:-28px;max-height:2.2em;">Sosyal Medya Haber</div>'
                        logo = '<div style="float:left;width:50px;height:50px;margin-top:-15px;"><img src="https://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc4/41526_100001935657063_1679909262_t.jpg" /> </div>';
                    }

                    var fb = '<div style="float:left;width:60px"><div style="width:50px" id="bfbbhl' + value.haberID + '" class="fb-like" data-href="http://' + window.location.host + '/Default.aspx?hid=' + value.haberID + '" data-send="false" data-layout="button_count" data-width="60" data-show-faces="false"></div></div>';
                    var fb2 = '<div style="float:left;width:80px"><div style="width:90px" id="afbbhl2' + value.haberID + '" class="fb-like" data-href="http://' + window.location.host + '/Default.aspx?hid=' + value.haberID + '" data-send="false" data-layout="button_count" data-width="80" action="recommend" data-show-faces="false"></div></div>';
                    var send = '<div style="float:left;width:70px"><div style="width:80px" id="sfbbhl' + value.haberID + '" class="fb-send" data-href="http://' + window.location.host + '/Default.aspx?hid=' + value.haberID + '" data-send="false"  data-width="110" data-show-faces="false"></div></div>';
                    var gp = '<div style="float:left;width:50px;margin-left:4px"><div style="width:90px"><g:plusone size="small" href="http://' + window.location.host + '/Default.aspx?hid=' + value.haberID + '"></g:plusone></div></div> ';
                    var tw = '<div style="float:left;width:100px;margin-left:4px"><iframe allowtransparency="true" frameborder="0"  data-via="sosyalmedyahaber" scrolling="no" data-text="" src="//platform.twitter.com/widgets/tweet_button.html?url=' + eurl + '&text=' + value.haberBaslik + '&lang=tr" style="float:left;width:90px; height:20px;z-index:9999"></iframe></div>';
                    var acBtn = '<div id="ac' + value.haberID + '"style="font-size:10px;font-weight:bold;border-color:Green;border-width:thin;border-style:solid;z-index:9999" class="curr links fnt solyuzdeyuz"> <span style="float:right"><img width="60px" height="25"  src="Styles/images/AC.jpg" /></span> </div>';
                    var acbtn2 = '<span id="acbtn' + value.haberID + '" style="float:left;margin-left:20px;border-color:Green;border-width:thin;border-style:solid;" class="curr"><img width="60" height="17"  src="Styles/images/AC.jpg" /></span>';

                    var haber = '<div style=" float:left; width: 98%"  id="haberOzet' + value.haberID + '"><div class="transparan" id="transparent' + value.haberID + '">&nbsp</div> <div id="haber' + value.haberID + '" class="ui-widget  haberKaydi" style="float:left;z-index:1;margin-left:8px;margin-top:-90px;width:95%;heigth:350px;background-color:#FBFBFD;padding-bottom:10px;border-top-width:0px; border-left-width:0px;border-right-width:0px; border-bottom-color:#E9E9E9;border-bottom-style:solid;border-bottom-width:1px;">' + baslik + logo + res + '<div style="font-size:11px;float:left;width:67%;vertical-align:top;padding-bottom:5px;margin-left:5px;" id="ozet' + value.haberID + '"><span class="links fnt" style="font-size:11px;font-weight:bold;text-transform:uppercase">' + value.haberBaslik + '</span></br><span style="float:left;text-overflow: ellipsis;overflow:hidden;font-style:italic;max-height:4.8em;">' + (value.ozet == null ? "" : value.ozet.substr(0, 140) + '<span class="devam"> devamı...</span>') + '</span></div></div></div></div>';

                   // CreateNewLikeButton2('bfbbhl' + value.haberID);
                   // CreateNewLikeButton2('afbbhl2' + value.haberID);
                    $('#haberAkis').append(haber);
                    if (value.ekTipi != null) {
                        if (value.ekTipi == "V") {
                            $('.haberDisVideo' + value.haberID).mediaelementplayer({

                                // if the <video width> is not specified, this is the default
                                defaultVideoWidth: 80,
                                // if the <video height> is not specified, this is the default
                                defaultVideoHeight: 80,
                                // if set, overrides <video width>
                                videoWidth: 80,
                                // if set, overrides <video height>
                                videoHeight: 80,
                                // width of audio player
                                audioWidth: 80,
                                // height of audio player
                                audioHeight: 5,
                                // initial volume when the player starts
                                startVolume: 0.8,
                                // useful for <audio> player loops
                                loop: false,
                                // enables Flash and Silverlight to resize to content size
                                enableAutosize: true,
                                // the order of controls you want on the control bar (and other plugins below)
                                features: ['playpause', 'volume'],
                                pauseOtherPlayers: false,
                                // automatically selects a <track> element
                                startLanguage: '',
                                // a list of languages to auto-translate via Google
                                translations: [],
                                // a dropdownlist of automatic translations
                                translationSelector: false,
                                // key for tranlsations
                                googleApiKey: ''

                            });
                        }
                    }
                    var hid = value.haberID;
                    $('#transparent' + hid).hover(function () { $(this).addClass("kategoriHaberleriHvr"); ; $(this).css("cursor", "pointer"); }, function () { $(this).removeClass("kategoriHaberleriHvr"); }).click(function () { $('#haber' + value.haberID).click(); }); ;
                    $('#haber' + value.haberID).click(function () {
                        $('#haber' + value.haberID).hide();
                        $('#transparent' + hid).hide();
                        $('#buttonzz' + hid).hide();
                        haberGosterV2(value.haberID);
                    });

                    $('#acbtn' + value.haberID).click(function () {
                        $('#haber' + value.haberID).click();
                    });

                });


                ekranAyarla();
                $('body').unblock();

//                var gphtml = '    <script type="text/javascript">    window.___gcfg = { lang: "tr" };    (function () {' +
//                    'var po = document.createElement("script"); po.type = "text/javascript"; po.async = true;' +
//                   ' po.src = "https://apis.google.com/js/plusone.js";' +
//                  '  var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(po, s);' +
//                   ' })();            </script>';
//                $('#haberAkisScr').append(gphtml);
                //  $('#anaSayfaSag').css("height", $('#anaSayfaSag').height() + 100 + "px");
                if (haberID) {
                    $('#haber' + haberID).hide("slow");
                    $('#transparent' + haberID).hide();
                    $('#buttonzz' + haberID).hide();
                    haberGosterV2(haberID);

                }
                var ekstraHaber = '<div id="btnEkstraHaber" style="width:98%;text-align:center;height:80px;background-color:black;color:white;float:left" class="fnt curr">Diğer Haberler İçin Tıklayınız</div>';
                if (data.d.length == 50) {
                    sayfa = sayfa + 1;
                    $('#btnEkstraHaber').remove();
                    $('#haberAkis').append(ekstraHaber);
                } else {
                    $('#btnEkstraHaber').remove();
                }
                $('#btnEkstraHaber').click(function () {
                    kategoriHaberleriGetir(kategoriID, haberID, 'He');
                });
            } else {
                $('body').unblock();
            }

        },
        error: function (xhr, data, textStatus) {
            ekranAc();
            hataver(xhr, status, Error);
        }
    });
    //$('#haberAkisScr').tinyscrollbar_update('relative');
}
function kategoriHaberleriGetirEski(kategoriID, haberID, temizleme) {
    $('body').block({
        theme: true,
        message: "Haberler Getiriliyor...",
        css: { border: '3px solid #a00' }
    });

    haberAkisEkrani();
  
    var json = { kategoriID: kategoriID, sayfa: sayfa };
    $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "mainFuncs.aspx/kategoriHaberleriniGetir",
        data: $.toJSON(json),
        dataType: "json",
        success: function (data) {
            var json = { sparam: "seciliKategori", s: kategoriID };
            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: "mainFuncs.aspx/SessionYaz",
                data: $.toJSON(json),
                dataType: "json",
                success: function (data) {
                },
                error: function (xhr, data, textStatus) {

                }
            });
            if (!temizleme) {
                $('#haberAkis').html("");
            }
            var ustBosluk = '<div class="solyuzdeyuz" style="height:42px">&nbsp</div>';
            if (data.d != null) {

                $.each(data.d, function (key, value) {
                    var eu = 'http://' + window.location.host + '/haberEkleri/' + value.haberID + '/' + value.haberResmi;
                    var resim = '<div style="width:15%;float:left;margin-left:5px;padding-right:5px;" id="resim' + value.haberID + '" ><img height=80 width=80 src="http://' + window.location.host + '/haberEkleri/' + value.haberID + '/' + value.haberResmi + '" /></div>';
                    var haberVideo = '<div style="width:15%;float:left;margin-left:5px;padding-right:5px;"><video preload="auto" style="float:left" class="haberDisVideo' + value.haberID + '" id="haberDisVideo' + value.haberID + '" src="' + eu + '" width="80" height="80" > </video></div>';


                    var res = '<div style="width:15%;float:left;margin-left:5px;padding-right:5px;">&nbsp</div>';
                    if (value.ekTipi != null) {
                        res = value.ekTipi == "R" ? resim : haberVideo;
                    }

                    var logo = value.logo != null ? '<div style="float:left;width:50px;height:50px;margin-top:-15px;">' + value.logo + '  </div>' : "";
                    var eurl = encodeURIComponent('http://' + window.location.host + '/Default.aspx?hid=' + value.haberID);
                    var baslik = '<div class="fnt solyuzdeyuz " style="font-size:11px;font-weight:bold;margin-top:-28px;max-height:2.2em;">' + value.kategoriAdi + '</div>';

                    if (value.ozelSayfa == 'T') {
                        baslik = '<div class="fnt solyuzdeyuz " style="font-size:11px;font-weight:bold;margin-top:-28px;max-height:2.2em;">Sosyal Medya Haber</div>'
                        logo = '<div style="float:left;width:50px;height:50px;margin-top:-15px;"><img src="https://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc4/41526_100001935657063_1679909262_t.jpg" /> </div>';
                    }

                    var fb = '<div style="float:left;width:60px"><div style="width:50px" id="bfbbhl' + value.haberID + '" class="fb-like" data-href="http://' + window.location.host + '/Default.aspx?hid=' + value.haberID + '" data-send="false" data-layout="button_count" data-width="60" data-show-faces="false"></div></div>';
                    var fb2 = '<div style="float:left;width:80px"><div style="width:90px" id="afbbhl2' + value.haberID + '" class="fb-like" data-href="http://' + window.location.host + '/Default.aspx?hid=' + value.haberID + '" data-send="false" data-layout="button_count" data-width="80" action="recommend" data-show-faces="false"></div></div>';
                    var send = '<div style="float:left;width:70px"><div style="width:80px" id="sfbbhl' + value.haberID + '" class="fb-send" data-href="http://' + window.location.host + '/Default.aspx?hid=' + value.haberID + '" data-send="false"  data-width="110" data-show-faces="false"></div></div>';
                    var gp = '<div style="float:left;width:50px;margin-left:4px"><div style="width:90px"><g:plusone size="small" href="http://' + window.location.host + '/Default.aspx?hid=' + value.haberID + '"></g:plusone></div></div> ';
                    var tw = '<div style="float:left;width:100px;margin-left:4px"><iframe allowtransparency="true" frameborder="0"  data-via="sosyalmedyahaber" scrolling="no" data-text="" src="//platform.twitter.com/widgets/tweet_button.html?url=' + eurl + '&text=' + value.haberBaslik + '&lang=tr" style="float:left;width:90px; height:20px;z-index:9999"></iframe></div>';
                    var acBtn = '<div id="ac' + value.haberID + '"style="font-size:10px;font-weight:bold;border-color:Green;border-width:thin;border-style:solid;z-index:9999" class="curr links fnt solyuzdeyuz"> <span style="float:right"><img width="60px" height="25"  src="Styles/images/AC.jpg" /></span> </div>';
                    var acbtn2 = '<span id="acbtn' + value.haberID + '" style="float:left;margin-left:20px;border-color:Green;border-width:thin;border-style:solid;" class="curr"><img width="60" height="17"  src="Styles/images/AC.jpg" /></span>';

                    var haber = '<div style=" float:left; width: 98%"  id="haberOzet' + value.haberID + '"><div class="transparan" id="transparent' + value.haberID + '">&nbsp</div> <div id="haber' + value.haberID + '" class="ui-widget  haberKaydi" style="float:left;z-index:1;margin-left:8px;margin-top:-85px;width:95%;heigth:350px;background-color:#FBFBFD;padding-bottom:10px;border-top-width:0px; border-left-width:0px;border-right-width:0px; border-bottom-color:#E9E9E9;border-bottom-style:solid;border-bottom-width:1px;">' + baslik + logo + res + '<div style="font-size:11px;float:left;width:70%;vertical-align:top;padding-bottom:5px;margin-left:7px;" id="ozet' + value.haberID + '"><span class="links fnt" style="font-size:11px;font-weight:bold;text-transform:uppercase">' + value.haberBaslik + '</span></br><span style="float:left;text-overflow: ellipsis;overflow:hidden;font-style:italic;max-height:4.8em;">' + (value.ozet == null ? "" : value.ozet) + '</span></div></div><div id="buttonzz' + value.haberID + '" class="solyuzdeyuz" style="margin-top:8px">' + gp + tw + send + fb2 + fb + acbtn2 + '</div></div></div>';

                    CreateNewLikeButton2('bfbbhl' + value.haberID);
                    CreateNewLikeButton2('afbbhl2' + value.haberID);
                    $('#haberAkis').append(haber);
                    if (value.ekTipi != null) {
                        if (value.ekTipi == "V") {
                            $('.haberDisVideo' + value.haberID).mediaelementplayer({

                                // if the <video width> is not specified, this is the default
                                defaultVideoWidth: 80,
                                // if the <video height> is not specified, this is the default
                                defaultVideoHeight: 80,
                                // if set, overrides <video width>
                                videoWidth: 80,
                                // if set, overrides <video height>
                                videoHeight: 80,
                                // width of audio player
                                audioWidth: 80,
                                // height of audio player
                                audioHeight: 5,
                                // initial volume when the player starts
                                startVolume: 0.8,
                                // useful for <audio> player loops
                                loop: false,
                                // enables Flash and Silverlight to resize to content size
                                enableAutosize: true,
                                // the order of controls you want on the control bar (and other plugins below)
                                features: ['playpause', 'volume'],
                                pauseOtherPlayers: false,
                                // automatically selects a <track> element
                                startLanguage: '',
                                // a list of languages to auto-translate via Google
                                translations: [],
                                // a dropdownlist of automatic translations
                                translationSelector: false,
                                // key for tranlsations
                                googleApiKey: ''

                            });
                        }
                    }
                    var hid = value.haberID;
                    $('#transparent' + hid).hover(function () { $(this).addClass("kategoriHaberleriHvr"); ; $(this).css("cursor", "pointer"); }, function () { $(this).removeClass("kategoriHaberleriHvr"); }).click(function () { $('#haber' + value.haberID).click(); }); ;
                    $('#haber' + value.haberID).click(function () {
                        $('#haber' + value.haberID).hide();
                        $('#transparent' + hid).hide();
                        $('#buttonzz' + hid).hide();
                        haberGosterV2(value.haberID);
                    });

                    $('#acbtn' + value.haberID).click(function () {
                        $('#haber' + value.haberID).click();
                    });

                });


                ekranAyarla();
                $('body').unblock();

                var gphtml = '    <script type="text/javascript">    window.___gcfg = { lang: "tr" };    (function () {' +
                    'var po = document.createElement("script"); po.type = "text/javascript"; po.async = true;' +
                   ' po.src = "https://apis.google.com/js/plusone.js";' +
                  '  var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(po, s);' +
                   ' })();            </script>';
                $('#haberAkisScr').append(gphtml);
                //  $('#anaSayfaSag').css("height", $('#anaSayfaSag').height() + 100 + "px");
                if (haberID) {
                    $('#haber' + haberID).hide("slow");
                    $('#transparent' + haberID).hide();
                    $('#buttonzz' + haberID).hide();
                    haberGosterV2(haberID);

                }
                var ekstraHaber = '<div id="btnEkstraHaber" style="width:98%;text-align:center;height:30px;background-color:black;color:white" class="fnt curr">Diğer Haberler İçin Tıklayınız</div>';
                if (data.d.length == 50) {
                    sayfa = sayfa + 1;
                    $('#btnEkstraHaber').remove();
                    $('#haberAkisScr').append(ekstraHaber);
                } else {
                    $('#btnEkstraHaber').remove();
                }
                $('#btnEkstraHaber').click(function () {
                    kategoriHaberleriGetir(kategoriID, haberID, 'He');
                });
            } else {
                $('body').unblock();
            }

        },
        error: function (xhr, data, textStatus) {
            ekranAc();
            hataver(xhr, status, Error);
        }
    });
    //$('#haberAkisScr').tinyscrollbar_update('relative');
}
var yarim1 = "";
var yarim2 = "";
var tamboy = "";
function reklamlariGetir() {

    var json = {};
    $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "mainFuncs.aspx/reklamTanimlariGetir",
        data: $.toJSON(json),
        dataType: "json",
        success: function (data) {
            $('#divReklamlar').html('');


            var i = 0;
            if (data.d != null) {

                var eurl, baslik, fb, gp, tw;
                if (data.d.tamboyAcik == 'T') {
                     eurl = encodeURIComponent('http://' + window.location.host+'/reklamResimleri/t/' + data.d.tamboyresim);
                     baslik = '<div class="fnt solyuzdeyuz" style="font-size:11px;font-weight:bold;margin-top:-28px;">www.sosyalmedyahaber.org</div>';
                     fb = '<div style="float:left;width:100px"><div  id="fbbhltamboy" class="fb-like" data-href="http://' + window.location.host + '"/reklamResimleri/t/' + data.d.tamboyresim + '" data-send="false" data-layout="button_count" data-width="90" data-show-faces="false"></div></div>';
                     fb2 = '<div style="float:left;width:90px"><div  id="fbbhltamboy2" class="fb-like" action="recommend"  data-href="http:/' + window.location.host + '/reklamResimleri/t/' + data.d.tamboyresim + '" data-send="false" data-layout="button_count" data-width="50" data-show-faces="false"></div></div>';
                     var send = '<div style="float:left;width:80px"><div style="width:80px" id="tfbbhl" class="fb-send" data-href="http://' + window.location.host + '/reklamResimleri/t/' + data.d.tamboyresim + '"   data-width="110" data-show-faces="false"></div></div>';
                     //var fb2 = '<div style="float:left;width:210px"><div id="fbbhl2' + value.haberID + '" class="fb-like" data-href="http://'+ window.location.host+'/Default.aspx?hid=' + value.haberID + '" data-send="true" data-layout="button_count" data-width="100" action="recommend" data-show-faces="false"></div></div>';
                     gp = '<div style="float:left;width:50px;margin-left:4px"><g:plusone size="small" href="http://' + window.location.host + '/reklamResimleri/t/' + data.d.tamboyresim + '"></g:plusone></div>';
                     tw = '<iframe allowtransparency="true" frameborder="0"  data-via="sosyalmedyahaber" scrolling="no" data-text="" src="//platform.twitter.com/widgets/tweet_button.html?url=' + eurl + '&text=sosyalmedyahaber.org&lang=tr" style="float:left;width:100px; height:20px;"></iframe>';

                     //                     tamboy = '<div id="tamBoyReklam"  class="tamboyreklam uiListLightblack "><a href="http://' + data.d.tamboylink + '" target="blank"> <img  src="http://' + window.location.host + '/reklamResimleri/t/' + data.d.tamboyresim + '"/></a></div><div style="width:100%;float:left;">' + gp + tw + send + fb + '</div>';
                     tamboy = '<div id="tamBoyReklam"  class="tamboyreklam uiListLightblack "><a href="http://' + data.d.tamboylink + '" target="blank"> <img  src="http://' + window.location.host + '/reklamResimleri/t/' + data.d.tamboyresim + '"/></a></div>';
                   // CreateNewLikeButton2('fbbhltamboy');
                    i = i + 1;
                    tamboyacik = 'T';
                } else {
                    tamboy = '<div class="tamboyreklam">Google Reklami Gelecek</div>';
                    tamboyacik = 'F';
                }

                if (data.d.y1Acik == 'T') {
                    eurl = encodeURIComponent('http://' + window.location.host + '/reklamResimleri/1/' + data.d.yayin1);
                    
                    baslik = '<div class="fnt solyuzdeyuz" style="font-size:11px;font-weight:bold;margin-top:-28px;">www.sosyalmedyahaber.org</div>';
                    fb = '<div style="float:left;width:100px"><div  id="fbbhlyarim1" class="fb-like" data-href="http://' + window.location.host + '/reklamResimleri/1/' + data.d.yayin1 + '" data-send="false" data-layout="button_count" data-width="90" data-show-faces="false"></div></div>';
                    fb2 = '<div style="float:left;width:90px"><div  id="fbbhlyarim1fb2" class="fb-like"  action="recommend"  data-href="http://' + window.location.host + '/reklamResimleri/1/' + data.d.yayin1 + '" data-send="false" data-layout="button_count" data-width="50" data-show-faces="false"></div></div>';
                    //var fb2 = '<div style="float:left;width:210px"><div id="fbbhl2' + value.haberID + '" class="fb-like" data-href="http://' + window.location.host + '/Default.aspx?hid=' + value.haberID + '" data-send="true" data-layout="button_count" data-width="100" action="recommend" data-show-faces="false"></div></div>';
                    gp = '<div style="float:left;width:50px;margin-left:4px"><g:plusone size="small" href="http://' + window.location.host + '/reklamResimleri/1/' + data.d.yayin1 + '"></g:plusone></div> ';
                    tw = '<iframe allowtransparency="true" frameborder="0"  data-via="sosyalmedyahaber" scrolling="no" data-text="" src="//platform.twitter.com/widgets/tweet_button.html?url=' + eurl + '&text=sosyalmedyahaber.org&lang=tr" style="float:left;width:100px; height:20px;"></iframe>';
                    send = '<div style="float:left;width:80px"><div style="width:90px" id="r1fbbhl" class="fb-send" data-href="http://' + window.location.host + '/reklamResimleri/1/' + data.d.yayin1 + '" data-send="false"  data-width="110" data-show-faces="false"></div></div>';

                    //                    yarim1 = '<div id="reklamAlani1" class="reklamAlani1 uiListLightblack"><a href="http://' + data.d.reklamlink1 + '" target="blank"><img  src="http://' + window.location.host + '/reklamResimleri/1/' + data.d.yayin1 + '"/></a></div><div style="width:100%;float:left">' + gp + tw + send + fb + '</div>';
                    yarim1 = '<div id="reklamAlani1" class="reklamAlani1 uiListLightblack"><a href="http://' + data.d.reklamlink1 + '" target="blank"><img  src="http://' + window.location.host + '/reklamResimleri/1/' + data.d.yayin1 + '"/></a></div>';
                    i = i + 1;
                    yarim1acik = 'T';
                  //  CreateNewLikeButton2('fbbhlyarim1');
                } else {
                    yarim1 = '<div class="reklamAlani1">Google Reklami Gelecek</div>';
                    i = i + 1;
                    yarim1acik = 'F';
                }

                if (data.d.y2Acik == 'T') {
                    eurl = encodeURIComponent('http://' + window.location.host + '/reklamResimleri/2/' + data.d.yayin2);
                    baslik = '<div class="fnt solyuzdeyuz" style="font-size:11px;font-weight:bold;margin-top:-28px;">www.sosyalmedyahaber.org</div>';
                    fb = '<div style="float:left;width:100px"><div  id="fbbhlyarim2" class="fb-like" data-href="http://' + window.location.host + '/reklamResimleri/2/' + data.d.yayin2 + '" data-send="false" data-layout="button_count" data-width="90" data-show-faces="false"></div></div>';
                    fb2 = '<div style="float:left;width:90px"><div  id="fbbhlyarim2fb2" class="fb-like" action="recommend" data-href="http://' + window.location.host + '/reklamResimleri/2/' + data.d.yayin2 + '" data-send="false" data-layout="button_count" data-width="50" data-show-faces="false"></div></div>';
                    //var fb2 = '<div style="float:left;width:210px"><div id="fbbhl2' + value.haberID + '" class="fb-like" data-href="http://' + window.location.host + '/Default.aspx?hid=' + value.haberID + '" data-send="true" data-layout="button_count" data-width="100" action="recommend" data-show-faces="false"></div></div>';
                    gp = '<div style="float:left;width:50px;margin-left:4px"><g:plusone size="small" href="http://' + window.location.host + '/reklamResimleri/2/' + data.d.yayin2 + '"></g:plusone></div>';
                    tw = '<iframe allowtransparency="true" frameborder="0"  data-via="sosyalmedyahaber" scrolling="no" data-text="" src="//platform.twitter.com/widgets/tweet_button.html?url=' + eurl + '&text=sosyalmedyahaber.org&lang=tr" style="float:left;width:100px; height:20px;"></iframe>';
                    send = '<div style="float:left;width:80px"><div style="width:80px" id="r2fbbhl" class="fb-send" data-href="http://' + window.location.host + '/reklamResimleri/2/' + data.d.yayin2 + '" data-send="false"  data-width="110" data-show-faces="false"></div></div>';

                    //                    yarim2 = '<div id="reklamAlani2" class="reklamAlani2 uiListLightblack"><a href="http://' + data.d.reklamlink2 + '" target="blank"><img   src="http://' + window.location.host + '/reklamResimleri/2/' + data.d.yayin2 + '"/></a></div><div style="width:100%;float:left">' + gp + tw + send + fb + '</div>';
                    yarim2 = '<div id="reklamAlani2" class="reklamAlani2 uiListLightblack"><a href="http://' + data.d.reklamlink2 + '" target="blank"><img   src="http://' + window.location.host + '/reklamResimleri/2/' + data.d.yayin2 + '"/></a></div>';
                    i = i + 1;
                    yarim2acik = 'T';
                  //  CreateNewLikeButton2('fbbhlyarim2');
                } else {
                    yarim2 = '<div class="reklamAlani2">Google Reklami Gelecek</div>';
                    i = i + 1;
                    yarim2acik = 'F';
                }

                seciliReklam = "y";
                reklamDegistir();
            }


        },
        error: function (xhr, data, textStatus) {
            ekranAc();
            hataver(xhr, status, Error);
        }
    });
}
var seciliReklam = null;
var yarim1acik;
var yarim2acik;
var tamboyacik;
function reklamDegistir() {
    $('#divReklamlar').html('');

    if (seciliReklam == "t") {
        seciliReklam = "y"
    } else {
        seciliReklam = "t";
    }

    if (seciliReklam == "y") {
        $('#divReklamlar').append(yarim1);
        $('#divReklamlar').append(yarim2);
//        CreateNewLikeButton('fbbhlyarim1');
//        CreateNewLikeButton('fbbhlyarim1fb2');
//        CreateNewLikeButton('fbbhlyarim2');
//        CreateNewLikeButton('fbbhlyarim2fb2');
        if (yarim1acik == 'T') {
           // reklamSayiArttir("y1");

        }
        if (yarim2acik == 'T') {
          //  reklamSayiArttir("y2");
        }
    }

    if (seciliReklam == "t") {
        $('#divReklamlar').append(tamboy);
//        CreateNewLikeButton('fbbhltamboy');
//        CreateNewLikeButton('fbbhltamboy2');
        if (tamboyacik== 'T') {
         //   reklamSayiArttir("t");
        }
    }
   // reklamZamanla();
    //seciliReklam = reklamTipi;
    if (reklamDegisimZamani == null) {
        reklamZamanla(5000);
    } else {
        reklamZamanla(reklamDegisimZamani);
    }

//    var gphtml = '    <script type="text/javascript">    window.___gcfg = { lang: "tr" };    (function () {' +
//                    'var po = document.createElement("script"); po.type = "text/javascript"; po.async = true;' +
//                   ' po.src = "https://apis.google.com/js/plusone.js";' +
//                  '  var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(po, s);' +
//                   ' })();            </script>';
//    $('#divReklamlar').append(gphtml);
}
var reklamDegisimZamani = null;
function reklamZamanla(t) {
     setTimeout("reklamDegistir()", t*1000);
}

function haberGosterEkrani() {
    $('#haberAkisScr2').show();
    $('#haberAkisScr').hide();
}
function haberAkisEkrani() {
    $('#haberAkisScr2').hide();
    $('#haberAkisScr').show();

}
function reklamSayiArttir(alanTipi) {
    var json = { alanAdi: alanTipi };
    $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "mainFuncs.aspx/reklamSayacArttir",
        data: $.toJSON(json),
        dataType: "json",
        success: function (data) {       
        },
        error: function (xhr, data, textStatus) {
           
        }
    });
}
function haberGoster(id) {
    if (id) {
        ekranKilitle("Haber Yükleniyor");
        $('#haberGoster').html("");
        haberGosterEkrani();
        var json = { haberID: id };
        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "mainFuncs.aspx/haberGetir",
            data: $.toJSON(json),
            dataType: "json",
            success: function (data) {
                if (data.d != null) {
                    var ht = '<div id="haberGosterim' + data.d.haber.haberID + '" class="ui-widget ui-widget-content haberGoster"style="float:left;width:97%;margin-left:1.5%" ><div style="float:left;width:97%;margin-left:2px;margin-top:2px" > ' + data.d.haber.haberBaslik + '<span class="geri ui-icon ui-icon-closethick" style="float:right"></span> </div><div style="margin-left:13px;font-size:11px;width:95%;float:left;" class=""><span style="display:inline-block" id="spnHaberResmi"></span>' + (data.d.haber.haber == null ? "" : data.d.haber.haber) + '</div><div id="haberEkleri" class="solyuzdeyuz"></div><div class="solyuzdeyuz"><div style="float:right" id="btnHaberGeri">Kapat</div></div></div>';
                    $('#haberGoster').append(ht);
                    $('.geri').css("cursor", "pointer").click(function () {
                        haberAkisEkrani();
                        if (skid) {
                            kategoriHaberleriGetir(skid);
                            $('#haberGoster').html("");
                        }
                        $('#haberGoster').html("");
                    });
                    var eurl = encodeURIComponent('http://' + window.location.host + '/Default.aspx?hid=' + data.d.haber.haberID);
                    var tw = '<div  style="width:100px;float:left;margin-left:5px" ><div style="float: left"><iframe allowtransparency="true" frameborder="0" url="http://' + window.location.host + '/Default.aspx?hid=' + data.d.haber.haberID + '" data-via="" scrolling="no" src="//platform.twitter.com/widgets/tweet_button.html?url=' + eurl + '&text=www.sosyalmedyahaber.org&lang=tr" style="float:left;width:130px; height:20px;"></iframe></div></div>';
                    var gp = '<div style="float:left;width:50px;margin-left:4px"><g:plusone size="small" href="http://' + window.location.host + '/Default.aspx?hid=' + data.d.haber.haberID + '"></g:plusone></div> ';
                    var fb = '<div style="float:left;width:300px;"><div style="float:left;width:160px" class="fblike" id="like' + data.d.haber.haberID + '"></div></div>';
                    // var tw = '<iframe allowtransparency="true" frameborder="0" scrolling="no" src="//platform.twitte

//                    $('#haberGoster').append(gp).append(tw).append(fb);
                    //$('#haberGoster').append(tw);
                    $('#haberGoster').append(gp).append(tw).append(fb);
                    $('#spnHaberResmi').html('<img class="curr" style="display:inline-block" width="150" height="100" src="./haberEkleri/' + id + '/' + data.d.haber.haberResmi + '"/><span id="spnResimSayisi' + data.d.haber.haberID + '" class="fnt" style="display:none"></span>');
                    CreateNewLikeButton(window.location.host + '/Default.aspx?hid=' + data.d.haber.haberID, 'like' + data.d.haber.haberID);
                    //  twttrr();
                    $('#btnHaberGeri').button().click(function () {
                        haberAkisEkrani();
                        if (skid) {
                            kategoriHaberleriGetir(skid);
                            $('#haberGoster').html("");
                        }
                    });
                    haberEkleriOlusturV2(data.d.ekler, id);
                    ekranAyarla();
                   // metaAyarla(data.d.haber.haberBaslik);
                    ekranAc();
                    //$('#haberAkisScr2').tinyscrollbar_update('relative');
                } else {
                    acilisKategorisiAl();
                }
            },
            error: function (xhr, data, textStatus) {
                ekranAc();
                hataver(xhr, status, Error);
            }
        });
    }
}
var sonSecilenhaberID = null;
function haberGosterV2(id) {
    if (id) {
        $('body').block({
            theme: true,
            message: "Haberler Getiriliyor...",
            css: { border: '3px solid #a00' }
        });   
        //$('#haberGoster').html("");
        //haberGosterEkrani();

        var json = { haberID: id };
        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "mainFuncs.aspx/haberGetir",
            data: $.toJSON(json),
            dataType: "json",
            success: function (data) {
                if (data.d != null) {
                    sonHaberKapat();
                    sonSecilenhaberID = data.d.haber.haberID;

                    var ozet = data.d.haber.ozet;
                    var ht = '<div id="haberGosterim' + data.d.haber.haberID + '" class="ui-widget haberGoster uiListLightBottom" style="z-index:1;float:left;width:97%;margin-left:3px;margin-top:10px" ><div style="margin-left:13px;font-size:11px;width:95%;float:left;" ><div class="solyuzdeyuz" ><span style="display:inline-block;width:40%;float:left;" id="spnHaberResmi' + data.d.haber.haberID + '"></span><span class="geri ui-icon ui-icon-closethick" style="margin-left: 390px;"></span><span class="fnt  links" style="width:60%;margin-bottom:10px;float:left;margin-top:2px;font-size:12px;font-weight:bold;text-transform: uppercase;padding-bottom:5px;max-height:3.5em; ">' + data.d.haber.haberBaslik + '</span>' + (ozet == null ? 'www.sosyalmedyahaber.org' : '<span style="font-style:italic">' + ozet + '<span>') + '</div>' + (data.d.haber.haber == null ? "&nbsp" : data.d.haber.haber) + '</div><div id="haberEkleri' + data.d.haber.haberID + '" class="solyuzdeyuz"></div><div id="haberbuttonz' + data.d.haber.haberID + '" class="solyuzdeyuz"></div><div class="solyuzdeyuz"></div><div id="altbosluk" style="height:5px;float:left"> &nbsp </div></div>';
                    $('#haberOzet' + id).append(ht);

                    var kapatbtn = '<div style="float:right;font-size:10px;font-weight:bold;border-color:Red;border-width:thin;border-style:solid;" class="links fnt" id="btnHaberGeri' + data.d.haber.haberID + '"> <img width="60" height="17" src="Styles/images/KAPAT.jpg" /> </div>';
                    var yuksek = '<div class="solyuzdeyuz" style="height:42px">&nbsp</div>';
                    var eurl = encodeURIComponent('http://' + window.location.host + '/Default.aspx?hid=' + data.d.haber.haberID);
                    //                    var tw = '<div  style="width:100px;float:left;margin-left:5px" ><div style="float: left;vertical-align:bottom"><iframe allowtransparency="true" frameborder="0" url="http://' + window.location.host + '/Default.aspx?hid=' + data.d.haber.haberID + '" data-via="" scrolling="no" src="//platform.twitter.com/widgets/tweet_button.html?url=' + eurl + '&text=' + eurl + ' ' + data.d.haber.haberBaslik + '&lang=tr" style="float:left;width:130px; height:20px;"></iframe></div></div>';
                    var tw = '<div  style="width:100px;float:left;margin-left:5px" ><div style="float: left;vertical-align:bottom"><iframe allowtransparency="true" frameborder="0" url="" data-via="sosyalmedyahaber" scrolling="no" src="//platform.twitter.com/widgets/tweet_button.html?url=' + eurl + '&text=' + data.d.haber.haberBaslik + '&lang=tr" style="float:left;width:130px; height:20px;"></iframe></div></div>';
                    var gp = '<div style="float:left;width:50px;margin-left:4px"><g:plusone size="small" href="http://' + window.location.host + '/Default.aspx?hid=' + data.d.haber.haberID + '"></g:plusone></div> ';
                    var fb = '<div style="float:left;width:70px"><div style="width:50px" id="likehaberGoster' + data.d.haber.haberID + '" class="fb-like" data-href="http://' + window.location.host + '/Default.aspx?hid=' + data.d.haber.haberID + '" data-send="false" data-layout="button_count" data-width="70" data-show-faces="false"></div></div>';
                    var fb2 = '<div style="float:left;width:90px"><div id="likehaberGoster2' + data.d.haber.haberID + '" class="fb-like" data-href="http://' + window.location.host + '/Default.aspx?hid=' + data.d.haber.haberID + '" data-send="false" data-layout="button_count" data-width="100" action="recommend" data-show-faces="false"></div></div>';
                    var send = '<div style="float:left;width:80px"><div style="width:80px" id="ihfbbhl" class="fb-send" data-href="http://' + window.location.host + '/Default.aspx?hid=' + data.d.haber.haberID + '" data-send="false"  data-width="110" data-show-faces="false"></div></div>';
                    //                    $('#haberbuttonz' + data.d.haber.haberID).append(gp).append(tw).append(send).append(fb2).append(fb).append(kapatbtn);
                    $('#haberbuttonz' + data.d.haber.haberID).append(tw).append(fb2).append(kapatbtn);

                    if (data.d.ekler != null) {
                        var haberResim = '<img class="curr" style="display:inline-block" width="150" height="100" src="./haberEkleri/' + id + '/' + data.d.ekler[0].ek + '"/><span id="spnResimSayisi' + data.d.haber.haberID + '" class="fnt" style="display:none"></span>';
                        var haberVideo = '<video class="haberVideo" id="haberVideo' + id + '" src="./haberEkleri/' + id + '/' + data.d.ekler[0].ek + '" width="150" height="150" > </video>';
                        var hresmi = data.d.ekler[0].ektipi == "R" ? haberResim : haberVideo;
                        $('#spnHaberResmi' + data.d.haber.haberID).html(hresmi);
                        $('#spnHaberResmi' + data.d.haber.haberID).append('<span style="margin-top:2px;width:100%;float: left;" id="haberResimSayisi' + data.d.haber.haberID + '"> </span>');
                        if (data.d.ekler[0].ektipi == "V") {
                            $('.haberVideo').mediaelementplayer({
                                // if the <video width> is not specified, this is the default
                                defaultVideoWidth: 150,
                                // if the <video height> is not specified, this is the default
                                defaultVideoHeight: 150,
                                // if set, overrides <video width>
                                videoWidth: 150,
                                // if set, overrides <video height>
                                videoHeight: 150,
                                // width of audio player
                                audioWidth: 150,
                                // height of audio player
                                audioHeight: 30,
                                // initial volume when the player starts
                                startVolume: 0.8,
                                // useful for <audio> player loops
                                loop: false,
                                // enables Flash and Silverlight to resize to content size
                                enableAutosize: true,
                                // the order of controls you want on the control bar (and other plugins below)
                                features: ['playpause', 'progress', 'volume', 'fullscreen'],
                                pauseOtherPlayers: false,
                                // automatically selects a <track> element
                                startLanguage: '',
                                // a list of languages to auto-translate via Google
                                translations: [],
                                // a dropdownlist of automatic translations
                                translationSelector: false,
                                // key for tranlsations
                                googleApiKey: ''

                            });
                        }
                        haberEkleriOlusturV2(data.d.ekler, id);
                    }

                    //$('#spnHaberResmi' + data.d.haber.haberID).html('<img class="curr" style="display:inline-block" width="150" height="100" src="./HaberResmi/' + id + '/' + data.d.haber.haberResmi + '"/><span id="spnResimSayisi' + data.d.haber.haberID + '" class="fnt" style="display:none"></span>');
                    //CreateNewLikeButton(window.location.host + '/Default.aspx?hid=' + data.d.haber.haberID, 'like' + data.d.haber.haberID);
                    //  twttrr();

                    $('#btnHaberGeri' + data.d.haber.haberID).click(function () {
                        //    haberAkisEkrani(); 
                        $('#haberVideo').remove();
                        $('#haberGosterim' + data.d.haber.haberID).html('').remove();
                        $('#haber' + id).show("slow");
                        sonSecilenhaberID = null;
                        $('#transparent' + id).show();
                        $('#buttonzz' + id).show();
                        ekranAyarla();
                    });
                    $('.geri').unbind('click');
                    $('.geri').click(function () {
                        //    haberAkisEkrani(); 
                        $('#haberVideo').remove();
                        $('#haberGosterim' + data.d.haber.haberID).html('').remove();
                        $('#haber' + id).show("slow");
                        sonSecilenhaberID = null;
                        $('#transparent' + id).show();
                        $('#buttonzz' + id).show();
                        ekranAyarla();
                    });
                    CreateNewLikeButton('likehaberGoster' + data.d.haber.haberID);
                    CreateNewLikeButton('likehaberGoster2' + data.d.haber.haberID);

                    //  ekranAyarla();
                    //metaAyarla(data.d.haber.haberBaslik);

                    var gphtml = '    <script type="text/javascript">    window.___gcfg = { lang: "tr" };    (function () {' +
                    'var po = document.createElement("script"); po.type = "text/javascript"; po.async = true;' +
                   ' po.src = "https://apis.google.com/js/plusone.js";' +
                  '  var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(po, s);' +
                   ' })();            </script>';
                    $('#haberAkisScr').append(gphtml);
                    //$('#anaSayfaSag').css("height", $('#anaSayfaSag').height() + 200 + "px");
                    ekranAc();
                    var t = $('#haberGosterim' + data.d.haber.haberID).position().top;
                    $(window).scrollTop(t - 78);
                    //$('#haberAkisScr2').tinyscrollbar_update('relative');
                } else {
                    acilisKategorisiAl();
                }
                $('body').unblock();
            },
            error: function (xhr, data, textStatus) {
                $('body').unblock();
                hataver(xhr, status, Error);
            }
        });
    }
}
function sonHaberKapat() {
    if (sonSecilenhaberID != null) {

        $('#btnHaberGeri' + sonSecilenhaberID).click();
    }
}
function haberEkleriOlusturV2(ekler, id) {
    if (ekler != null) {

        var toplamResim = 0;
        $.each(ekler, function (key, value) {
            var ht = "";
            if (value.ektipi == "R") {
                toplamResim = toplamResim + 1;
                
            }
            else {
                if (key != 0) {
                    ek = '<span  style="display:inline-block" ><video class="vid" id="video' + id + '" src="/haberEkleri/' + id + '/' + value.ek + '" width="400" height="300" > </video></span>';
                    var imgvid = "ui-icon ui-icon-video";
                    ht = '<div style="display:inline-block;padding-right:5px;padding-bottom:10px;"><span style="display:inline-block" class="' + imgvid + '" ></span>' + ek + '</div>'
                }
            }
           

            $('#haberEkleri' + id).append(ht);

        });

        if (ekler[0].ektipi == "R") {

            $('#spnHaberResmi' + id).click(function () {
                var resimler = new Array();
                $.each(ekler, function (key, value) {
                    if (value.ektipi == "R") {
                        resimler.push('http://' + window.location.host + '/haberEkleri/' + id + '/' + value.ek);
                    }
                });
                if (resimler.length > 0) {
                    $.fancybox(
                   resimler, {
                       'padding': 0,
                       'transitionIn': 'none',
                       'transitionOut': 'none',
                       'type': 'image',
                       'changeFade': 0,
                       'cyclic':true
                   });
                    //   $('#spnResimSayisi' + id).html('<p>'+resimler.length + " Resim</p>").show();
                }

           });
           $('#haberResimSayisi' + id).unbind("click");
           $('#haberResimSayisi' + id).click(function () {
               $('#spnHaberResmi' + id).click();
           });
       } else {
           $('#haberResimSayisi' + id).click(function () {
               var resimler = new Array();
               $.each(ekler, function (key, value) {
                   if (value.ektipi == "R") {
                       resimler.push('http://' + window.location.host + '/haberEkleri/' + id + '/' + value.ek);
                   }
               });
               if (resimler.length > 0) {
                   $.fancybox(
                   resimler, {
                       'padding': 0,
                       'transitionIn': 'none',
                       'transitionOut': 'none',
                       'type': 'image',
                       'changeFade': 0,                       
                       'cyclic':true,
                        'onComplete': function() {
                            $("#fancybox-wrap").css('z-index', '999999');
                        }
                   });
                   //   $('#spnResimSayisi' + id).html('<p>'+resimler.length + " Resim</p>").show();
               } 
           });
        }
           if (toplamResim > 1) {
            $('#haberResimSayisi' + id).append("Diğer resimler için tıklayın.").addClass("curr fnt links").show();
            }
        // $('.im').fancybox();
        $('#haberOzet' + id)
        if ($('#haberOzet'+id+' .vid').length > 0) {
            $('#haberOzet' + id + ' .vid').mediaelementplayer({
                // if the <video width> is not specified, this is the default
                defaultVideoWidth: 480,
                // if the <video height> is not specified, this is the default
                defaultVideoHeight: 270,
                // if set, overrides <video width>
                videoWidth: -1,
                // if set, overrides <video height>
                videoHeight: -1,
                // width of audio player
                audioWidth: 400,
                // height of audio player
                audioHeight: 30,
                // initial volume when the player starts
                startVolume: 0.8,
                // useful for <audio> player loops
                loop: false,                
                // enables Flash and Silverlight to resize to content size
                enableAutosize: true,
                // the order of controls you want on the control bar (and other plugins below)
                features: ['playpause', 'progress', 'current', 'duration', 'tracks', 'volume', 'fullscreen'],
                pauseOtherPlayers: false,
                // automatically selects a <track> element
                startLanguage: '',
                // a list of languages to auto-translate via Google
                translations: [],
                // a dropdownlist of automatic translations
                translationSelector: false,
                // key for tranlsations
                googleApiKey: ''

            });
        }

    }

}
function acilisKategorisiAl() {
    ekranKilitle("Haberler Yükleniyor");
    var json = {};
    $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "mainFuncs.aspx/acilisKategorisiGetir",
        data: $.toJSON(json),
        dataType: "json",
        success: function (data) {
            ekranAc();
            if (skid != null && skid != "" && parametreGetir("hid") == "" && parametreGetir("as") == "") {
                kategoriHaberleriGetir(skid);
                secilenKategoriID = skid;

            } else {

                if (parametreGetir("hid") != "" && parametreGetir("katid") != "") {
                    kategoriHaberleriGetir(parametreGetir("katid"), parametreGetir("hid"));
                    return;
                } else if (parametreGetir("hid") != "" && parametreGetir("katid") == "") {
                    ajaxCalistir({ haberID: parametreGetir("hid") }, "mainFuncs.aspx/haberKategorisiGetir", function (data) {
                        if (data.d != -1) {
                            kategoriHaberleriGetir(data.d, parametreGetir("hid"));
                        }
                    });
                    return;
                }
                if (data.d != null) {
                    kategoriHaberleriGetir(data.d);
                    okkoy($('#kategori' + data.d).attr("ustkatid"));
                    secilenKategoriID = data.d;
                    return;
                }
            }
            
        },
        error: function (xhr, data, textStatus) {
            ekranAc();
            hataver(xhr, status, Error);
        }
    });
}
function haberEkleriOlustur(ekler, id) {
    if (ekler != null) {


        $.each(ekler, function (key, value) {
            var imgvid = value.ektipi == "R" ? "ui-icon ui-icon-image" : "ui-icon ui-icon-video";
            var ek = value.ektipi == "R" ? '<a class="im" href="./haberEkleri/' + id + '/' + value.ek + '" title="' + value.ek + '" ><img  height=150;width=150; src="../haberEkleri/' + id + '/' + value.ek + '" alt=""/></a>' : '<span  style="display:inline-block" ><video class="vid" id="video' + id + '" src="../haberEkleri/' + id + '/' + value.ek + '" width="400" height="300" > </video></span>';

            var ht = '<div style="display:inline-block;padding-right:5px;padding-bottom:10px;"><span style="display:inline-block" class="' + imgvid + '" ></span>' + ek + '</div>'
            $('#haberEkleri' + id).append(ht);

        });

        $('.im').fancybox();
        $('video').mediaelementplayer({
            // if the <video width> is not specified, this is the default
            defaultVideoWidth: 480,
            // if the <video height> is not specified, this is the default
            defaultVideoHeight: 270,
            // if set, overrides <video width>
            videoWidth: -1,
            // if set, overrides <video height>
            videoHeight: -1,
            // width of audio player
            audioWidth: 400,
            // height of audio player
            audioHeight: 30,
            // initial volume when the player starts
            startVolume: 0.8,
            // useful for <audio> player loops
            loop: false,
            // enables Flash and Silverlight to resize to content size
            enableAutosize: true,
            // the order of controls you want on the control bar (and other plugins below)
            features: ['playpause', 'progress', 'current', 'duration', 'tracks', 'volume', 'fullscreen'],

            // automatically selects a <track> element
            startLanguage: '',
            // a list of languages to auto-translate via Google
            translations: [],
            // a dropdownlist of automatic translations
            translationSelector: false,
            // key for tranlsations
            googleApiKey: ''

        });


    }

}


function kategoriBoyuAyarla() {
    var h = $('#AnaSayfaSol').height();
    var t = h / 10;
    if (t > 50) {
        $('.ustKategoris').css("height", t + "px");
    } else {
        $('.ustKategoris').css("height", "50px");

    }
}
function kategoriUzerineGelince(value) {
    var h = $('#AnaSayfaSol').height();
    var a = h -160 ;

    $('#kat' + value).css("overflow-y", "auto").css("overflow-x","hidden") ;
            var s = $('#icerik' + value + '> .katkapla').length;
   //     if (s < 15) {
        
            var k = (s * 25);

            if (k > 250) {
                k = 250;
            }
            if (k < 130) {
                k = 130;
            }
            var c = ((h - (k)) / 9);

          //  $('body').css("overflow", "hidden");

            $('#AnaSayfaSolUst .ustKategoris[id!="' + $('#kat' + value.kategoriID) + '"]').css("height", c + "px");
            $('#kat' + value).css("height", k + "px").css("overflow", "scroll").css("overflow-x", "hidden");
           // ekranAyarla();

//        } else {
//            $('#AnaSayfaSolUst .ustKategoris[id!="' + $('#kat' + value.kategoriID) + '"]').css("height", "50px");
//            $('#kat' + value).css("height", a + "px").css("overflow", "auto");
//         
            //        }
//            if (secilenKategoriID) {
//                var ust = $('#kategori' + secilenKategoriID).position().top + 35;
//                var sol = $("#kategoriKapla" + secilenKategoriID).width() - 10;
//                $("#OK").css({ 'margin-top': ust + "px", 'margin-left': sol + "px" });
//            }
        };


        var secilenKategoriID;        
function kategoriUzerindenGidince(value) {
    kategoriBoyuAyarla();
  //  $('#kat' + value).scrollTop( $('#kategori' + secilenKategoriID).position().top - 20);
 //   $('#kat' + value).scrollTop(0);
//    if (secilenKategoriID) {
//        var ust = $('#kategori' + secilenKategoriID).position().top + 35;
//        var sol = $("#kategoriKapla" + secilenKategoriID).width() - 10;
//        $("#OK").css({ 'margin-top': ust + "px", 'margin-left': sol + "px" });
//    }
    // $("#OK").css({ 'margin-top': ust + "px", 'margin-left': sol + "px" });
    $('#kat' + value).css("overflow-x", "hidden");
   // $('body').css("overflow", "auto");
   // ekranAyarla();
}

function kategorileriGetir() {
    $("#AnaSayfaSolUst").html('');
    ekranKilitle("Haber Kategorileri Getiriliyor");
    var json = {};
    $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "mainFuncs.aspx/kategorileriGetir",
        data: $.toJSON(json),
        dataType: "json",
        success: function (data) {
            if (data.d != null) {
                $.each(data.d, function (key, value) {
                    if (value.ustKategoriID == -1) {

                        var ht = '<div style="" class="fnt ui-widget  ustKategoris curr" id="kat' + value.kategoriID + '"><div class=" baslikKategori fnt ui-state-active" style="position:fixed;float:left;width:424px;text-align:center; min-width:270px;font-weight:bold;font-size:11px;z-index:1005">' + value.kategoriAdi + '<span class="spnbaslik" id="katbaslik' + value.kategoriID + '"  style="float:right"></span> </div><div style="float:left;width:100%;margin-top:20px" id="icerik' + value.kategoriID + '"> </div> </div>';
                        $("#AnaSayfaSolUst").append(ht);
                        $('#kat' + value.kategoriID).hover(function () { kategoriUzerineGelince(value.kategoriID) }, function () { kategoriUzerindenGidince(value.kategoriID); });
                    } else {
                        // var fb = value.facebookLink == null ? "" : '<a href="' + value.facebookLink + '" target=_blank > <img src="./Styles/images/facebooklogoK.jpg" alt="Facebook Sayfamızı Ziyaret Edin"/></a>';

                       // var tw = value.twitterAdresi == null ? '<div style="float:left;width:110px;">&nbsp</div>' : '<div style="float:left;width:110px"> <iframe allowtransparency="true" frameborder="0" scrolling="no" src="//platform.twitter.com/widgets/follow_button.html?screen_name=' + value.twitterAdresi + '&lang=tr" style="width:105px; float:left;height:20px;padding-left:5px"></iframe></div>';
                        var tw2 = value.twitterAdresi == null ? '<div style="float:left;width:20px;margin-left:4px">&nbsp</div>' : '<div style="float:left;width:20px;margin-left:4px"><a href="http://www.twitter.com/' + value.twitterAdresi + '" target=_blank ><img height=20px width=20px src="./Styles/Twitter-icon2.png" alt="Twitter Sayfamızı Ziyaret Edin"/></a></div>';
                        //var fb = value.facebookLink == null ? "" : '<div class="curr" style="width:50px;float:left" id="facebbtn2' + value.kategoriID + '"><a target="_blank" href="' + value.facebookLink + '"> <img src="./Styles/images/facebooklogoK.jpg" alt="Facebook Sayfamızı Ziyaret Edin"/></a></div>';
                        //var fb = value.facebookLink == null ? '<div style="float:left;width:70px">&nbsp</div>' : '<div style="float:left;width:70px"><div id="fbb' + value.kategoriID + '" class="fb-like" data-href="' + value.facebookLink + '" data-send="false" data-layout="button_count" data-width="80" data-show-faces="false"></div></div>';
                        var fb2 = value.facebookLink == null ? '<div class="curr" style="width:25px;float:left;">&nbsp</div>' : '<div class="curr" style="width:25px;float:left;margin-left:4px" id="fbbtn' + value.kategoriID + '"><img style="float:left" width="20" height="20" src="./Styles/FaceBook_32x32.png" alt="Facebook Sayfamızı Ziyaret Edin"/></div>';
                        //var gp = value.gpno == "" ? '<div style="float:left;width:20px;margin-left:4px">&nbsp</div>' : '<div style="float:left;width:20px;margin-left:4px"><a href="http://plus.google.com/' + value.gpno + '" target=_blank ><img height=20px width=20px src="./Styles/gplus.png" alt="Google Plus Sayfamızı Ziyaret Edin"/></a></div>';

                        ht = '<div  class="katkapla" id="kategoriKapla' + value.kategoriID + '" style="float:left;min-width:390px;width:100%;"><div style="float:left;width:36%;min-width:160px;overflow:hidden">' +  tw2 + fb2 +  '</div><div style="width:60%;float:left;min-width:115px;margin-top:5px;font-size:12px" class="fnt hvr" ustkatid="' + value.ustKategoriID + '" katid="' + value.kategoriID + '" id="kategori' + value.kategoriID + '"><div id="can' + value.kategoriID + '" styles="float:left;width:100%;"><div  id="kategoriAdiclick' + value.kategoriID + ' class="kategoriAdiclick hvr fnt " style="float:left;width:100%;z-index:1101;font-size:11px;font-weight:bold" >' + value.kategoriAdi + '<span id="spnOK' + value.kategoriID + '"  style="float:right;display:none" class="spnOK ui-icon ui-icon-triangle-1-e"></span></div></div></div>';
                        $("#icerik" + value.ustKategoriID).append(ht);
                        $('#kategori' + value.kategoriID).unbind("click");
                        $('#kategori' + value.kategoriID).click(function () { sayfa = 0; kategoriHaberleriGetir($(this).attr("katid")); okkoy(value.ustKategoriID, value.kategoriID, value.facebookLink); $('#txtAra').val(''); });
                        $('#fbbtn' + value.kategoriID).unbind("click");
                        $('#fbbtn' + value.kategoriID).click(function () { fbEkraniOlustur(value.facebookLink); });
                       // CreateNewLikeButton2('fbb' + value.kategoriID);
                    }

                    //$('.hvr').hover(function () { $(this).addClass("ui-widget-header"); }, function () { $(this).removeClass("ui-widget-header") }).css("cursor", "pointer");
                    $('.hvr').hover(function () { $(this).addClass("hoverGradient"); }, function () { $(this).removeClass("hoverGradient") }).css("cursor", "pointer");
                    


                });

            } else {
                $("#AnaSayfaSolUst").html("Şu an sistemimizde çalışma yapılmaktadır. Lütfen az sonra tekrar deneyiniz.");
            }
            //$('#haberAkisScr').tinyscrollbar_update('relative');
            ekranAyarla();
            kategoriBoyuAyarla();
            //$('#AnaSayfaSolScr').tinyscrollbar();
            ekranAc();

            acilisKategorisiAl();

        },
        error: function (xhr, data, textStatus) {
            ekranAc();
            hataver(xhr, status, Error);
        }
    });
}
function fbEkraniOlustur(adres) {
    var ht = '<div id="fblikeboxx" class="fb-like-box" data-href="' + adres + '" data-width="292" data-show-faces="true" data-stream="true" data-header="true"></div>';
    $('#fbIcerik').html('');
    $('#fbIcerik').append(ht);
    CreateNewLikeButton2('fbIcerik');
    $('#dialFbEkrani').dialog("open");
}
function metaAyarla(desc) {
    $('meta[name=Description]').attr('content', desc);
}
function videoOynat(dosya) {
    $("#videoTV").attr("src", "/haberTV/" + dosya);
    var player = new MediaElementPlayer('#videoTV');
    player.pause();
    player.setSrc("/haberTV/" + dosya);
    player.play();


}
function yayinListesiGetir() {
    //   ekranKilitle("Yayın Listesi Yükleniyor");
    var json = {};
    $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "mainFuncs.aspx/tvYayinListesiGetir",
        data: $.toJSON(json),
        dataType: "json",
        success: function (data) {
            ekranAc();
            $('#yayinAkisi').html('');
            if (data.d != null) {
                $.each(data.d, function (key, value) {
                    var ht = '<div style="float:left;width:98%" id="vid' + value.yayinID + '" class="ui-state-default"><span style="float:left;width:100%" ><span  style="float:left;width:45px">' + value.baslangicSaati + '</span>' + value.programAdi + '</span></div>';
                    $('#yayinAkisi').append(ht);
                    //$('#vid' + value.yayinID).css("cursor", "pointer").click(function () { videoOynat(value.videoDosyasi) });
                })
            }
        },
        error: function (xhr, data, textStatus) {
            ekranAc();
            hataver(xhr, status, Error);
        }
    });
}


function yazarListesiGetir() {
    var ilanMetni = "";
    ajaxCalistir({}, "mainFuncs.aspx/yazarGetir", function (data) {
        $('#bannerBaslik2').html('<div class="solyuzdeyuz fnt triangle-isoscelesy" style="text-align:justify;font-size:11px;width:98%" ><div class="solyuzdeyuz" style="text-align:center;margin-bottom:0px">YAZARLARIMIZ</div>Sizde Kendi Alanınızda Yeteneğinize Güveniyorsanız,  Bu Alandaki Düşüncelerinizi Ve Haberlerinizi Okuyucularımızla Paylaşmayı Düşünüyorsanız. Bizimle İletişime Geçerek Belirlediğiniz Bir Veya Birkaç Sosyal Medya Haber Sayfalamızdan  Bir Yönetim Paneli Alıp Kendi Okuyucu Kitlenizi Oluşturabilir, Sayfamızın Gönüllü Yazarı Veya Temsilcisi Olabilirsiniz.</div>');

        if (data.d != null) {
            for (var i = 0; i < data.d.length; i++) {
                var ht = '<div style="float:left;width:140px;overflow:hide;height:40px" class="uiListLight triangle-isosceles"><span style="width:60px;float:left;margin-top:5px"><img width="50" height="50"  src="http://' + window.location.host + '/yazarFoto/' + data.d[i].resim + '" alt="Yazar Resim" /></span><span class="fnt" style="width:40%;float:left;font-size:11px;margin-top:5px">' + data.d[i].username + '</span>' + '<span class="fnt" style="width:40%;float:left;font-size:11px">' + (data.d[i].meslek == null ? "" : data.d[i].meslek) + '</span></div>';
             
                $('#divIlanlar2').append(ht);
            }

        }

    });
}

function ilanListesiGetir() {
    var ilanMetni = "";
    ajaxCalistir({}, "mainFuncs.aspx/ilanMetniGetir", function (data) {
        $('#bannerBaslik').html(data.d.replace("\n","<br/>"))
        ekranAc();
        ilanGetir();
    });
}
function ilanGetir() {
    var ilanMetni = "";
    ajaxCalistir({}, "mainFuncs.aspx/ilanListele", function (data) {
        $('#divIlanlar li').remove();
        if (data.d != null) {
            $.each(data.d, function (k, v) {
                var ht = '<li class="triangle-isosceles">' + v.ilanMetni + '</li>';
                $('#ilanul').append(ht);
                ekranAc();
            });
        }

        ekranAc();
    });
}
function haberAra(metin) {
    ekranKilitle("Haberler Aranıyor...");
    haberAkisEkrani();
    var json = { metin: metin };
    $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "mainFuncs.aspx/haberAra",
        data: $.toJSON(json),
        dataType: "json",
        success: function (data) {
            if (data.d != null) {
                $('#haberAkis').html("");
                $.each(data.d, function (key, value) {
                    var res = value.haberResmi != "default.jpg" ? '<div style="width:15%;float:left" id="resim' + value.haberID + '" ><img height=80 width=80 src="./HaberResmi/' + value.haberID + '/' + value.haberResmi + '" /></div>' : "";
                    var haber = '<div id="haber' + value.haberID + '" class="haberKaydi" style="margin-left:8px;margin-top:10px;width:95%;float:left;heigth:350px;padding-bottom:10px">' + res + '<div style="font-size:11px;float:left;width:70%;vertical-align:top;padding-bottom:5px;margin-left:7px;" id="ozet' + value.haberID + '"><strong>' + value.haberBaslik + '</strong></br>' + (value.ozet == null ? "" : value.ozet) + '</div></div>';
                    $('#haberAkis').append(haber);
                    $('#haber' + value.haberID).click(function () { haberGoster(value.haberID); });
                    // $('#haber' + value.haberID).hover(function () { $('#like' + value.haberID).show(); }, function () { $('#like' + value.haberID).hide(); });
                });
                $('.haberKaydi').hover(function () { $(this).addClass("ui-state-hover"); $(this).css("cursor", "pointer"); }, function () { $(this).removeClass("ui-state-hover"); });
                sayfa = sayfa + 1;
                ekranAyarla();
                ekranAc();
            } else {
                ekranAc();
            }

        },
        error: function (xhr, data, textStatus) {
            ekranAc();
            hataver(xhr, status, Error);
        }
    });
    //$('#haberAkisScr').tinyscrollbar_update('relative');
}



$(document).ready(function () {

    if ($(window).width() > 1249) {
        $('#divAltAra').css("margin-top", ($(window).height() - 110) + "px");
        $('#kontrolPaneli').width($('#fScreen').width() + 85);
        $('.baslikKategori ').css("position", "fixed");
        var l = (($(window).width() - 1250) / 2) + 940 + "px";
        var r = (($(window).width() - 1250) / 2) + 1288 + "px"
        $('#sagScrl').css("left", l);
        $('#divBannerEkrani').css("left", r);
        $('#divBannerEkrani2').css("left", (($(window).width() - 1250) / 2) - 25);
        // $('#counter').css("position", "fixed");
        $('#anaSayfaSag').css("position", "relative").css("margin-left", "450px");
        $('#AnaSayfaOrta').css("position", "fixed");
        $('#sagScrl').css("position", "fixed");
    }

    else {
        $('.fScreen').css("width", 1350 + "px");
        $('.fScreen').css("min-width", 1350 + "px");

        $('#anaSayfaSag').css("position", "static").css("margin-left", 0 + "px").css("float", "left");
        $('#AnaSayfaOrta').css("position", "static").css("margin-left", 0 + "px").css("float", "left");
        $('#sagScrl').css("position", "static").css("margin-left", 0 + "px").css("float", "left").css("min-width", 300 + "px");
        $('#divBannerEkrani').css("left", $(window).width() - 20);
        $('#divBannerEkrani2').css("left", 0);
        $('.ustBaslik').css("left", $('#AnaSayfaOrta').width());
        $('#divAltAra').css("margin-top", "0px").css("position", "relative");
        $('.baslikKategori ').css("position", "static");
        //  $('#counter').css("position", "static");
    }


    $('#yayinAkisi').height($(window).height() - 658 + "px");

    $('#btnIlanAra').button().click(function () {
        IlanBul();
    });


    $('#txtIlanBul').keypress(function (e) {

        if (e.which == 13) {

            IlanBul();
        }
    });

    ajaxCalistir({}, "mainFuncs.aspx/reklamZamaniGetir", function (data) {
        reklamDegisimZamani = data.d;
    });


    // $('#divReklamlar').css("height", ($(window).height() - $("#haberTV").height() - 150) + "px");

    $('.AnaSayfaOrta').css('height', ($(window).height() - $('.kontrolPaneli').height() - 4) + "px");
    $('.AnaSayfaOrta').css('max-height', ($(window).height() - $('.kontrolPaneli').height() - 4) + "px");


    $('#btnBanner').html($('#btnBanner').text().replace(/(.)/g, "$1<br />"));
    $('#btnBanner2').html($('#btnBanner2').text().replace(/(.)/g, "$1<br />"));
    $("#btnBanner").click(function () {
        //  $("#divBannerEkrani").toggle("slide", { from: { "margin-left": $(window).width() - $("#divBannerEkrani").width() + 25} }, 1000);

    });


    $("#bannerClik2").toggle(function () {
        $('#divIlanlar2').show();
        //$('#divIlanBul2').show();
        $('#bannerBaslik2').show();
        $('.baslikKategori').css("z-index", "0");
        var r = (($(window).width() - 1250) / 2) - 25;
        if ($(window).width() < 1250) {
            r = 0;
        }
        $("#divBannerEkrani2").animate({ "left": r, "width": 470 }, 1000);
        $('.bannerok2').html('<img  src="Styles/images/solok.png" width="20px" height="20px" />');

    }, function () {
        $('#divIlanlar2').hide();
        //$('#divIlanBul2').hide();
        $('#bannerBaslik2').hide();
        $
        var r = (($(window).width() - 1250) / 2) - 25;
        if ($(window).width() < 1250) {
            r = 0;
        }
        $('.bannerok2').html('<img  src="Styles/images/sagok.png" width="20px" height="20px" />');
        $("#divBannerEkrani2").animate({ "left": r, "width": 20 }, 1000, "", function () {
            $('.baslikKategori').css("z-index", "99999");
        });

    });

    $("#bannerClik").toggle(function () {
        $('#divIlanlar').show();
        $('#divIlanBul').show();
        $('#bannerBaslik').show();
        var r = (($(window).width() - 1250) / 2) + 1308;
        if ($(window).width() < 1250) {
            r = $(window).width() - 20;
        }
        $("#divBannerEkrani").animate({ "left": r - 370, "width": 370 }, 1000);
        $('.bannerok1').html('<img  src="Styles/images/sagok.png" width="20px" height="20px" />');
    }, function () {
        $('#divIlanlar').hide();
        $('#divIlanBul').hide();
        $('#bannerBaslik').hide();
        var r = (($(window).width() - 1250) / 2) + 1288;
        if ($(window).width() < 1250) {
            r = $(window).width() - 20;
        }
        $('.bannerok1').html('<img  src="Styles/images/solok.png" width="20px" height="20px" />');
        $("#divBannerEkrani").animate({ "left": r, "width": 20 }, 1000);
    });

    $('#dialFbEkrani').dialog({
        width: 350,
        height: 500,
        modal: true,
        autoOpen: false,
        buttons: {
            "Kapat": function () { $(this).dialog("close"); }
        }
    });
    // $('#divBannerEkrani').css("margin-left", ($(window).width() - 25) + "px");
    yayinListesiGetir();
    kategorileriGetir();
    ilanListesiGetir();
    yazarListesiGetir();
    //videoElementOlustur();
    
        videoGetir();
    
    $('#btnAnaSayfa').click(function () {
        var json = { sparam: "seciliKategori", s: null };
        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "mainFuncs.aspx/SessionYaz",
            data: $.toJSON(json),
            dataType: "json",
            success: function (data) {
                window.location = "Default.aspx";
            },
            error: function (xhr, data, textStatus) {

            }
        });

    });
    $('#btnAnket').click(function () {
        window.location = "anket.aspx";
    });
    $('#btnIletisim').click(function () {
        window.location = "iletisim.aspx";
    });
    $('#btnHaberBul').button().click(function () {
        var t = $('#txtAra').val();
        if (t == "" || t == null) {
            return;
        }
        haberAra(t);
    });
    reklamlariGetir();
    // ekranAyarla();
    istatistikGetir();

    $('#divLogo').click(function () { window.location = "Default.aspx" });

    $('#sagScrl').css("height", ($(window).height()) + "px");
    $('#sagScrl .viewport').css("height", ($(window).height()) + "px");
    //$('#sagScrl .overview').css("height", ($(window).height()) + "px");
    $('#sagScrl').tinyscrollbar();
    reklamSayiArttir("y1");
    reklamSayiArttir("y2");
    reklamSayiArttir("t");


});

$(window).resize(function () {

 //   $('.fScreen').css("width", ($(window).width() -50  )+"px");
    //$('.kapla').css("height", $(window).height() - 50);
   // $('#anaSayfaSag').css("width",($(window).width() - 450)+"px" );
    ekranAyarla();
    kategoriBoyuAyarla();
    // $('#haberAkisScr').tinyscrollbar_update('relative');
    //   $('#AnaSayfaSolScr').tinyscrollbar();
//    $('#divAltAra').css("margin-top", ($(window).height() - 80) + "px");

});
$(window).scroll(function () {
   // ekranAyarla();


});
function istatistikGetir() {
    ajaxCalistir({}, "mainFuncs.aspx/onlineKullaniciSayisi", function (data) {
        $('#counter').html('');
        $('#counter').append('<div>Aktif Kullanıcı : ' + data.d.aktif + '</div>');
        $('#counter').append('<div>Toplam Kullanıcı : ' + data.d.toplam + '</div>');
        $('#counter').append('<div>Ulaşabildiğimiz Kullanıcı  : ' + data.d.sosyal + '</div>');

    });

}
function ekranAyarla() {
  
    if ($(window).width() > 1249) {
        $('#divAltAra').css("margin-top", ($(window).height() - 110) + "px");
        $('#kontrolPaneli').width($('#fScreen').width()+85);
        $('.baslikKategori ').css("position", "fixed");
        var l = (($(window).width() - 1250) / 2) + 920 + "px";
        var r = (($(window).width() - 1250) / 2) + 1288 + "px"
        $('#sagScrl').css("left", l);
       // $('#counter').css("position", "fixed");
        $('#anaSayfaSag').css("position", "relative").css("margin-left", "450px");
        $('#AnaSayfaOrta').css("position", "fixed");
        $('#sagScrl').css("position", "fixed");
        $('#divBannerEkrani2').css("left", $('#kontrolPaneli').position().left - 25);
        $('#divBannerEkrani').css("left", r);
    }

    else {
        $('#kontrolPaneli').width($('#fScreen').width());
        $('#divAltAra').css("margin-top", ($(window).height() - 110) + "px");
        $('.fScreen').css("width", 1350 + "px");
        $('.fScreen').css("min-width", 1350 + "px");
        $('#anaSayfaSag').css("position", "static").css("margin-left", 0 + "px").css("float", "left");
        $('#AnaSayfaOrta').css("position", "static").css("margin-left", 0 + "px").css("float", "left");
        $('#sagScrl').css("position", "static").css("margin-left", 0 + "px").css("float", "left").css("min-width", 300 + "px");
        $('.ustBaslik').css("left", 0);
        $('#divAltAra').css("margin-top", "0px").css("position", "relative");
        $('.baslikKategori ').css("position", "static");
      //  $('#counter').css("position", "static");
        $('#divBannerEkrani').css("left", $(window).width() - 20);
    }

     l = (($(window).width() - 1250) / 2) + 943 + "px";
    $('#sagScrl').css("left", l);

    //  $('#kontrolPaneli').width($('#fScreen').width());


}


function videoGetir() {
    var tvs = parametreGetir("tv");
    if (tvs != "") {
        videoElementOlustur(decodeURIComponent(tvs));
    } else {
        ekranKilitle("Video Yükleniyor");
        var json = {};
        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "mainFuncs.aspx/tvVideoGetir",
            data: $.toJSON(json),
            dataType: "json",
            success: function (data) {
                ekranAc();
                if (data.d != null) {
                    videoElementOlustur(data.d)
                }
            },
            error: function (xhr, data, textStatus) {
                ekranAc();
                hataver(xhr, status, Error);
            }
        });
    }
}


function videoElementOlustur(isim) {

    if (isim) {
        $('#videoTV').attr("src", "/haberTV/" + isim)
    }
    var w = 250;
    var h = $('#tvSabit').height() ;
    if ($('#haberTV').width() > 339) {
        $('#videoTV').attr("width", $('#haberTV').width() + "px");
        $('#videoTV').attr("height", h + "px");
        w = $('#haberTV').width();
    } else {
        $('#videoTV').attr("width", 340);
    }
    eurl = encodeURIComponent('http://' + window.location.host + '/Default.aspx?tv=' + isim);
    var fb3 = '<div style="float:left;width:60px"><div id="fbteve" class="fb-like" data-href="http://' + window.location.host + '/Default.aspx?tv=' + isim + '" data-send="false" data-layout="button_count" data-width="70"  data-show-faces="false"></div></div>';
    var fb2 = '<div style="float:left;width:105px"><div id="fbteve" class="fb-like" data-href="http://' + window.location.host + '/Default.aspx?tv=' + isim + '" data-send="false" data-layout="button_count" data-width="70" action="recommend" data-show-faces="false"></div></div>';
    var fb = '<div style="float:left;width:60px"><div  id="fbteve2" class="fb-like" data-href="http://www.facebook.com/pages/Sosyal Medya Tv Haber/209184115834750" data-send="false" data-layout="button_count" data-width="50"  data-show-faces="false"></div></div>';
    var gp2 = '<div style="float:left;width:40px"><g:plusone size="small" href="http://' + window.location.host + '/Default.aspx??tv=' + isim + '"></g:plusone></div>';
    var tw = '<iframe allowtransparency="true" frameborder="0"  data-via="sosyalmedyahaber" scrolling="no"  src="//platform.twitter.com/widgets/tweet_button.html?url=' + eurl + '&text=' + eurl + '&lang=tr" style="float:left;width:65px; height:20px;"></iframe>';
    
   
    var tw2 = '<div style="float:left;width:110px"> <iframe allowtransparency="true" frameborder="0" scrolling="no" src="//platform.twitter.com/widgets/follow_button.html?screen_name=SosyalMdyaTvHbr&lang=tr" style="width:110px; float:left;height:20px;padding-left:5px"></iframe></div>';
    var send = '<div style="float:left;width:65px"><div style="width:65px"  class="fb-send" data-href="http://' + window.location.host + '/Default.aspx?tv=' + isim + '"   data-width="110" data-show-faces="false"></div></div>';
//    $('#fbTvBegen').append(gp2);
    //    $('#fbTvBegen').append(tw2);
    //    CreateNewLikeButton2('fbteve2');
    //    $('#fbTvBegen').append(send).append(fb3);
    $('#fbTvBegen').append(tw);
    $('#fbTvBegen').append(fb2);
    CreateNewLikeButton2('fbteve');


 //   $('#fbTvBegen').append(fb2);
    //CreateNewLikeButton(window.location.host + 'http://' + window.location.host + '/Default.aspx?tv=' + isim, 'fbTvBegen',1);
    $('#videoTV').mediaelementplayer({
       
        plugins: ['flash'],
        flashName: 'flashmediaelement.swf',
        defaultVideoWidth: w,
        // if the <video height> is not specified, this is the default
        defaultVideoHeight: h,
        // if set, overrides <video width>
        videoWidth:w,
        // if set, overrides <video height>
        videoHeight:h,
        // width of audio player
        audioWidth: 200,
        // height of audio player
        audioHeight: 30,
        // initial volume when the player starts
        startVolume: 0.0,
        // useful for <audio> player loops
        loop: true,
        pauseOtherPlayers: false,
        // enables Flash and Silverlight to resize to content size
        enableAutosize: false,
        // the order of controls you want on the control bar (and other plugins below)
        features: ['fullscreen', 'volume','progress', 'current', 'duration', 'tracks'],

        // automatically selects a <track> element
        startLanguage: '',
        // a list of languages to auto-translate via Google
        translations: [],
        // a dropdownlist of automatic translations
        translationSelector: false,
        // key for tranlsations
        googleApiKey: '',
        success: function (mediaElement, domObject) {
            mediaElement.play();
        }

    });
    $('#videoTV').unbind('click');

}